%*******************************************************************************
%*
%*   Copyright ©2009 Alexandru Marin
%*
%*   This file is part of nwave/pMRI C library.
%*
%*   This project started as an MSc degree project during a
%*   stage at the Paris-Est university, under joint supervision of prof.
%*   Bogdan Ionescu (Image Analysis and Processing Laboratory, "Politehica"
%*   University of Bucharest), Caroline Chaux and Jean-Christophe Pesquet
%*   (Laboratoire d'Informatique, Université Paris-Est, Institut Gaspard Monge).
%*
%*   nwave/pMRI C libray is free software: you can redistribute it and/or modify
%*   it under the terms of the GNU General Public License as published by
%*   the Free Software Foundation, either version 2 of the License, or
%*   (at your option) any later version.
%*
%*   nwave/pMRI C libray is distributed in the hope that it will be useful,
%*   but WITHOUT ANY WARRANTY; without even the implied warranty of
%*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%*   GNU General Public License for more details.
%*
%*   You should have received a copy of the GNU General Public License
%*   along with nwave/pMRI C library. If not, see <http://www.gnu.org/licenses/>
%*
%*******************************************************************************


%
% function dwt_write_filter(filtername)
%
% Writes specified fitler (which must be in the matlab filter database)
% to a file, into the format expected by the ND DWT C implementation.
%
% The format of the file is as follows:
% - each row contains the filter of a band, with coefficients in reversed
%   order
% - first M rows (where M is the number of bands) are decompositions
%   filters and next M are reconstruction filters
%
function dwt_write_filter(filtername)

[LO_D,HI_D,LO_R,HI_R] = wfilters(filtername);
mat = flipdim([LO_D;HI_D;LO_R;HI_R],2);
mri_write_matrix([filtername '.csv'], mat, 9);